<?php

// Get variables
$id = get_input('user_id');
$brief = get_input('brief');
$client_id = get_input('client_id');

if ($id == 'me') {
    $userid = get_loggedin_userid();
} else {
    $userid = $id;
}

$userEntity = get_entity($userid);

if($userEntity) {
    $user = userToArray($userEntity, $client_id, $brief);
    if($id == 'me') {
        $user['email'] = $userEntity->email;
    }
    $result = export_result(200, $user);
} else {
    $result = export_result(400, "Cannot find user id #$userid#");
}

echo json_encode($result);
?>